flag=false;
function DrawImage(ImgD,ImgWidth,ImgHeight){ 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0)
	{ 
		flag=true; 
		if((image.width>ImgWidth)&&(image.height>ImgHeight))
		{ 
			if((image.width/image.height)<(ImgWidth/ImgHeight))
			{
				ImgD.hieght=ImgHeight;
				ImgD.width=image.width*ImgHeight/image.height;
			}
			else if((image.width/image.height)==(ImgWidth/ImgHeight))
			{
				ImgD.hieght=ImgHeight;
				ImgD.width=ImgWidth;
			}
			else
			{
				ImgD.height=image.height*ImgWidth/image.width;
				ImgD.width=ImgWidth;
			}
		}
		else if((image.width=ImgWidth)&&(image.height=ImgHeight))	
		{
			ImgD.height=ImgHeight; 
			ImgD.width=ImgWidth; 
		}
		else if((image.width<ImgWidth)&&(image.height<ImgHeight))
		{
			ImgD.height=ImgHeight; 
			ImgD.width=ImgWidth; 
		}
		else if((image.width<ImgWidth)&&(image.height>ImgHeight))
		{
			ImgD.hieght=ImgHeight;
			ImgD.width=image.width*ImgHeight/image.height;
		}
		else if((image.width>ImgWidth)&&(image.height<ImgHeight))
		{
			ImgD.height=image.height*ImgWidth/image.width;
			ImgD.width=ImgWidth;
		}
	} 
} 